package com.hns.its.persistence.jpa;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.NoRepositoryBean;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

@NoRepositoryBean
public interface GenericRepository<T, ID extends Serializable> extends JpaRepository<T, ID> {

	public Page<T> findAll(String jpql, Pageable pageable);

	public Page<T> findAllBySql(String sql, Pageable pageable);
	
	public List<T> findByProps(Map<String, Object> props);
	
	public T findSingleByProps(Map<String, Object> props);

	public <T> Page<T> findAllBySql(String sql, Collection<SearchFilter> filters, Pageable pageable, Class cls);

	public <T> List<T> findAllBySql(String sql, Collection<SearchFilter> filters, Class cls);

	public <T> T findSingleBySql(String sql, Collection<SearchFilter> filters, Class cls);

	public <T> Page<T> findAllBySql(String sql, Pageable pageable, Class cls, Object... params);

    public <T> List<T> findAllBySql(String sql, Class cls, Object... params);

    public <T> List<T> findAllBySqlSort(String sql, Pageable pageable, Class cls, Object... params);

    public <T> T findSingleBySql(String sql, Class cls, Object... params);

    public Integer countSql(String sql, Object... params);

    public Page<Map<String,Object>> findAllBySqlMap(String sql, Collection<SearchFilter> filters, Pageable pageable);

	public List<Map<String,Object>> findAllBySqlMap(String sql, Collection<SearchFilter> filters);

	public Map<String,Object> findSingleBySqlMap(String sql, Collection<SearchFilter> filters);

	public Page<Map<String,Object>> findAllBySqlMap(String sql, Pageable pageable, Object... params);

	public List<Map<String,Object>> findAllBySqlMap(String sql, Object... params);

	public List<Map<String,Object>> findAllBySqlMapSort(String sql, Pageable pageable, Object... params);
    
    public Map<String,Object> findSingleBySqlMap(String sql, Object... params);

	public List findAllBySql(String sql);

	public T findSingleByProp(String propName, Object propValue);

	public List<T> findByProp(String propName, Object propValue);

	public boolean exists(String propName, Object propValue);
	
	public void executeUpdate(String sql, Object... params);

}